#ifndef __THREAD_POOL_H__
#define __THREAD_POOL_H__

// #define DEBUG
#define CLOSE_INFO_PRT
#define THREAD_POOL_SIZE (5) ///< 线程池大小
#define TASK_MAX_SIZE (20)   ///< 任务队列大小

typedef void (*THRD_FUNC)(void *);

typedef struct ThreadPool THREAD_POOL;

///< 任务优先级枚举
typedef enum TaskPriority
{
    TASK_PRIORITY_LOW,                         ///< 优先级：低
    TASK_PRIORITY_MID,                         ///< 优先级：中
    TASK_PRIORITY_HIGH,                        ///< 优先级：高
    TASK_PRIORITY_IMMEDIATELY,                 ///< 优先级：立即执行
    TASK_PRIORITY_DEFAULT = TASK_PRIORITY_MID, ///< 优先级：默认
} TASK_PRIORITY;

/**
 * @fn        thread_pool_init
 * @brief     线程池初始化
 *
 * @param     [in] size   线程池线程个数
 *
 * @return    THREAD_POOL*   成功返回 THREAD_POOL 指针，失败返回 NULL
 */
THREAD_POOL *thread_pool_init(unsigned int size);

/**
 * @fn        thread_pool_add_task
 * @brief     向线程池添加任务
 *
 * @param     [in] pool      线程池
 * @param     [in] func      任务函数
 * @param     [in] arg       任务函数参数，无参数填 NULL
 *
 */
int thread_pool_add_task(THREAD_POOL *pool, THRD_FUNC func, void *arg);

/**
 * @fn        thread_pool_destroy
 * @brief     销毁线程池
 *
 * @param     [in] pool      线程池指针
 *
 */
void thread_pool_destroy(THREAD_POOL *pool);

/**
 * @fn        printfThreadPoolVersion
 * @brief     打印线程池版本信息
 *
 */
void printfThreadPoolVersion();

#endif /* !__THREAD_POOL_H__ */
